package sessionBeanTest;


/*
 void addClub(Club club);

	Club findClub(int id);

	void removeClub(Club club);

	int removeClubById(int id);

	void updateClub(Club club);

	List<Club> getClubListWithMembre();

	List<Club> getClubListWithClubAmis();

	List<Club> getClubListWithAvancement();

	void refresh(Club c);

	void flush();
 */

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import interfaceBeanRemote.SessionInvestisseurRemote;
import interfaceBeanRemote.sessionClubRemote;

import javax.naming.Context;
import javax.naming.InitialContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;


import entityBean.Club;
import entityBean.Investisseur;

public class ClubTest {
	Context ctx3;
	sessionClubRemote clubBean;
	SessionInvestisseurRemote investisseurBean;
	
	@Before
	public void setUp() throws Exception {

		ctx3= new InitialContext();

		ctx3.addToEnvironment(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
		ctx3.addToEnvironment(InitialContext.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
		ctx3.addToEnvironment(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
		clubBean=(sessionClubRemote) ctx3.lookup("sessionClub/remote");
		investisseurBean=(SessionInvestisseurRemote) ctx3.lookup("SessionInvestisseur/remote");
	}

	@After
	public void tearDown() throws Exception {
	}

	
	@Test
	public void testAddClub(){
		Club club4 =new Club();
		club4.setNom("club");
		clubBean.addClub(club4); 
	}
	
	@Test
	public void testUpdateClub(){
		
		Club club3=clubBean.findClub(1);
		club3.setNom("clubUpdate");
		clubBean.updateClub(club3);
		
		Club club4=clubBean.findClub(1);
		assertEquals("clubUpdate",club4.getNom());
		
		clubBean.removeClubById2(1);
	}
	
	@Test
	public void testRemoveClub(){
		Club club5 =new Club();
		club5.setNom("club");
		clubBean.addClub(club5); 
		clubBean.removeClub(club5);
	}
	
	@Test
	public void testFindClub(){
		Club club =new Club();
		club.setNom("club");
		clubBean.addClub(club); 
		Club club2=clubBean.findClub(2);
		assertEquals("club",club2.getNom());
	
	}
	
	
	
	
	
	

}
